#include <vector>
#include <iostream>
using namespace std;

typedef pair<short, short> location;
typedef vector<string> text;
typedef vector<location> loc;
typedef pair<text*, loc*> text_loc;

text_loc* separate_word(const vector<string> *text_file){
	vector<string> *words = new vector<string>;
	vector<location> *locations = new vector<location>;
	short line_pos = 0;
	
	for(; line_pos < text_file->size(); ++line_pos){
		short word_pos = 0;
		string textline = (*text_file)[line_pos];
		string::size_type pos = 0, prev_pos = 0;
		
		while((pos = textline.find_first_of(' ', pos)) != string::npos){
			words->push_back(textline.substr(prev_pos, pos - prev_pos));
			locations->push_back(make_pair(line_pos, word_pos));
			++word_pos;
			prev_pos = ++pos;
		}
		
		words->push_back(textline.substr(prev_pos, pos - prev_pos));
		locations->push_back(make_pair(line_pos, word_pos));
	}
	
	
	
	return new text_loc(words, location);
}